< previous page page_326 next page >

Page 326
TABLE 12.3. SETTING THE PROPERTIES TO BIND A TEXTBOX TO THE DATA ENVIRONMENT.
ControlPropertyValue
txtEmpIDDataSourcedeNorthWind
DataMembercmdEmployees
DataFieldEmployeeID

The first and third properties should be familiar to you; however, the second one, DataMember, is new. When you select a Data Environment as a data source, the DataMember allows you to specify which command in the Data Environment list you want to use. Finally, add the following code to the default form:
Private Sub cmdNext_Click()
deNorthWind.rscmdEmployees.MoveNext
txtEmployeeName.Text = deNorthWind.rscmdEmployees.Fields!firstname & _
                   & deNorthWind.rscmdEmployees.Fields!lastname
End Sub

Private Sub cmdPrev_Click()
deNorthWind.rscmdEmployees.MovePrevious
txtEmployeeName.Text = deNorthWind.rscmdEmployees.Fields!firstname & _
                   & deNorthWind.rscmdEmployees.Fields!lastname
End Sub

Private Sub cmdQuit_Click()
End
End Sub

Private Sub Form_Load()
txtEmployeeName.Text = deNorthWind.rscmdEmployees.Fields!firstname & _
                   & deNorthWind.rscmdEmployees.Fields!lastname
End Sub
Now run the application and try clicking the two command buttons to see how the Data Environment connection works the same as a Data control.
Caution
To keep this example short, you will not add any programmatic updates or EOF/BOF processing to this application. If you try to move past the End or Beginning of the query, you will receive an error message from the database.

As you can see, the Data Environment is every bit as good as the other data access methods and can be used wherever you would use a Data control or Data Access Object. Now that you have seen how you can use the Data Environment by itself in your application, continue to the next section to see how to create data reports for your application by using the Data Report Designer.

 
< previous page page_326 next page >

If you like this book, buy it!